/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.bar.carta.model.impl;

import com.bar.carta.model.TipoIdioma;
import com.bar.carta.model.TipoIdiomaModel;
import com.bar.carta.model.TipoIdiomaSoap;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.List;

/**
 * The base model implementation for the TipoIdioma service. Represents a row in the &quot;carta_TipoIdioma&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.bar.carta.model.TipoIdiomaModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link TipoIdiomaImpl}.
 * </p>
 *
 * @author pgonzalm
 * @see TipoIdiomaImpl
 * @see com.bar.carta.model.TipoIdioma
 * @see com.bar.carta.model.TipoIdiomaModel
 * @generated
 */
@JSON(strict = true)
public class TipoIdiomaModelImpl extends BaseModelImpl<TipoIdioma>
	implements TipoIdiomaModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a tipo idioma model instance should use the {@link com.bar.carta.model.TipoIdioma} interface instead.
	 */
	public static final String TABLE_NAME = "carta_TipoIdioma";
	public static final Object[][] TABLE_COLUMNS = {
			{ "tipoIdiomaId", Types.BIGINT },
			{ "tipoId", Types.BIGINT },
			{ "name", Types.VARCHAR },
			{ "descripcion", Types.VARCHAR },
			{ "idioma", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table carta_TipoIdioma (tipoIdiomaId LONG not null primary key,tipoId LONG,name VARCHAR(75) null,descripcion VARCHAR(75) null,idioma INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table carta_TipoIdioma";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.bar.carta.model.TipoIdioma"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.bar.carta.model.TipoIdioma"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static TipoIdioma toModel(TipoIdiomaSoap soapModel) {
		TipoIdioma model = new TipoIdiomaImpl();

		model.setTipoIdiomaId(soapModel.getTipoIdiomaId());
		model.setTipoId(soapModel.getTipoId());
		model.setName(soapModel.getName());
		model.setDescripcion(soapModel.getDescripcion());
		model.setIdioma(soapModel.getIdioma());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<TipoIdioma> toModels(TipoIdiomaSoap[] soapModels) {
		List<TipoIdioma> models = new ArrayList<TipoIdioma>(soapModels.length);

		for (TipoIdiomaSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.bar.carta.model.TipoIdioma"));

	public TipoIdiomaModelImpl() {
	}

	public long getPrimaryKey() {
		return _tipoIdiomaId;
	}

	public void setPrimaryKey(long primaryKey) {
		setTipoIdiomaId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_tipoIdiomaId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return TipoIdioma.class;
	}

	public String getModelClassName() {
		return TipoIdioma.class.getName();
	}

	@JSON
	public long getTipoIdiomaId() {
		return _tipoIdiomaId;
	}

	public void setTipoIdiomaId(long tipoIdiomaId) {
		_tipoIdiomaId = tipoIdiomaId;
	}

	@JSON
	public long getTipoId() {
		return _tipoId;
	}

	public void setTipoId(long tipoId) {
		_tipoId = tipoId;
	}

	@JSON
	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	public void setName(String name) {
		_name = name;
	}

	@JSON
	public String getDescripcion() {
		if (_descripcion == null) {
			return StringPool.BLANK;
		}
		else {
			return _descripcion;
		}
	}

	public void setDescripcion(String descripcion) {
		_descripcion = descripcion;
	}

	@JSON
	public int getIdioma() {
		return _idioma;
	}

	public void setIdioma(int idioma) {
		_idioma = idioma;
	}

	@Override
	public TipoIdioma toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (TipoIdioma)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					TipoIdioma.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		TipoIdiomaImpl tipoIdiomaImpl = new TipoIdiomaImpl();

		tipoIdiomaImpl.setTipoIdiomaId(getTipoIdiomaId());
		tipoIdiomaImpl.setTipoId(getTipoId());
		tipoIdiomaImpl.setName(getName());
		tipoIdiomaImpl.setDescripcion(getDescripcion());
		tipoIdiomaImpl.setIdioma(getIdioma());

		tipoIdiomaImpl.resetOriginalValues();

		return tipoIdiomaImpl;
	}

	public int compareTo(TipoIdioma tipoIdioma) {
		long primaryKey = tipoIdioma.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		TipoIdioma tipoIdioma = null;

		try {
			tipoIdioma = (TipoIdioma)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = tipoIdioma.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<TipoIdioma> toCacheModel() {
		TipoIdiomaCacheModel tipoIdiomaCacheModel = new TipoIdiomaCacheModel();

		tipoIdiomaCacheModel.tipoIdiomaId = getTipoIdiomaId();

		tipoIdiomaCacheModel.tipoId = getTipoId();

		tipoIdiomaCacheModel.name = getName();

		String name = tipoIdiomaCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			tipoIdiomaCacheModel.name = null;
		}

		tipoIdiomaCacheModel.descripcion = getDescripcion();

		String descripcion = tipoIdiomaCacheModel.descripcion;

		if ((descripcion != null) && (descripcion.length() == 0)) {
			tipoIdiomaCacheModel.descripcion = null;
		}

		tipoIdiomaCacheModel.idioma = getIdioma();

		return tipoIdiomaCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{tipoIdiomaId=");
		sb.append(getTipoIdiomaId());
		sb.append(", tipoId=");
		sb.append(getTipoId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", descripcion=");
		sb.append(getDescripcion());
		sb.append(", idioma=");
		sb.append(getIdioma());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("com.bar.carta.model.TipoIdioma");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>tipoIdiomaId</column-name><column-value><![CDATA[");
		sb.append(getTipoIdiomaId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tipoId</column-name><column-value><![CDATA[");
		sb.append(getTipoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>descripcion</column-name><column-value><![CDATA[");
		sb.append(getDescripcion());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>idioma</column-name><column-value><![CDATA[");
		sb.append(getIdioma());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = TipoIdioma.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			TipoIdioma.class
		};
	private long _tipoIdiomaId;
	private long _tipoId;
	private String _name;
	private String _descripcion;
	private int _idioma;
	private transient ExpandoBridge _expandoBridge;
	private TipoIdioma _escapedModelProxy;
}